package org.gitman.agentplatform.ui.actions;

import java.awt.event.ActionEvent;

import org.gitman.agentplatform.core.exceptions.NoGraphException;
import org.gitman.agentplatform.ui.api.View;
import org.gitman.agentplatform.ui.api.View.MessageType;

public class StartEditingAction extends UIAction{

	public StartEditingAction(){
		super("Start Editing");
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		try {
			graphEditor.startEditing();
		} catch (NoGraphException ex) {
			graphEditor.createGraph();
			platformManager.newSimulation();	
			try {
				graphEditor.startEditing();
			} catch (NoGraphException e1) {
				View.showMessage(e1.getMessage(), MessageType.ERROR);
				e1.printStackTrace();
			}
		}	
	}

}
